package com.xbang.attendance.web.action.warehouse.stock;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.xbang.attendance.entity.stock.InventoryExchange;
import com.xbang.attendance.service.InventoryService;
import com.demo2do.lighturl.annotation.Action;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;

public class ExchangeDetailSearch extends SearchActionSupport {

	@Autowired
	private InventoryService inventoryService;

	private List<InventoryExchange> inventoryExchanges = new ArrayList<InventoryExchange>();
	
	private String sourceWarehouseCode;
	
	@Action("/warehouse/stock-exchange-detail/list/${sourceWarehouseCode}")
	public String list() throws Exception {
		String hqlSentence = "FROM InventoryExchange inventoryExchange WHERE 1 = 1 ";
		searchComponent.addSearchElement("eq.inventoryExchange.sourceWarehouse.code", sourceWarehouseCode);
		Result result = inventoryService.searchByPage(hqlSentence, searchComponent, page);
		inventoryExchanges = result.getItems();
		page = result.getPage();

		return "stock-exchange-detail-search";
	}
	
	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub
		
	}

	public InventoryService getInventoryService() {
		return inventoryService;
	}

	public void setInventoryService(InventoryService inventoryService) {
		this.inventoryService = inventoryService;
	}

	public List<InventoryExchange> getInventoryExchanges() {
		return inventoryExchanges;
	}

	public void setInventoryExchanges(List<InventoryExchange> inventoryExchanges) {
		this.inventoryExchanges = inventoryExchanges;
	}

	public String getSourceWarehouseCode() {
		return sourceWarehouseCode;
	}

	public void setSourceWarehouseCode(String sourceWarehouseCode) {
		this.sourceWarehouseCode = sourceWarehouseCode;
	}
	
}
